package com.zs.ktsms.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author ZhouShuang
 * @version 17
 * @Title
 * @date 2025/5/31 下午9:02
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseMessage <T>{
    private Integer code ; //业务码
    private String msg ; //响应信息
    private T data; // 响应数据

    /**
     * 成功的响应(带数据)
     * @param msg
     * @param data
     * @return
     * @param <T>
     */
    public static <T> ResponseMessage<T> success(String msg,T data){
        return new ResponseMessage<T>(200,msg,data);
    }

    /**
     * 成功的响应(不带数据)
     * @param msg
     * @return
     * @param <T>
     */
    public static <T> ResponseMessage<T> success(String msg){
        return new ResponseMessage<>(200,msg,null);
    }

    /**
     * 失败的响应(不带数据)
     * @param msg
     * @return
     * @param <T>
     */
    public static <T> ResponseMessage<T> error(String msg){
        return new ResponseMessage<>(500,msg,null);
    }

    /**
     * 失败的响应(带数据)
     * @param msg
     * @param data
     * @return
     * @param <T>
     */
    public static <T> ResponseMessage<T> error(String msg,T data){
        return new ResponseMessage<>(500,msg,data);
    }

}
